<template>
  <div>
    姓名<input type="text" v-model="name" /> 年龄<input
      type="text"
      v-model="age"
    />
    <button @click="add">添加</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: "",
      age: "",
    };
  },
  methods: {
    add() {
      this.$store.commit("add", { name: this.name, age: this.age });
      //commit 调用vuex里mutation方法 commit只能有两个参数
    },
  },
  created() {},
  mounted() {},
  components: {},
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped></style>
